#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickView>
#include "CUtil.h"
#include "CLongScreenShot.h"
#include "CLongScreenShotInApp.h"
#include <QApplication>


int main(int argc, char *argv[])
{
    qSetMessagePattern("[%{type}] %{time yyyy-MM-dd hh:mm:ss.zzz}  %{function}:%{line} %{message}");


    QApplication app(argc, argv);


    QQmlApplicationEngine engine;

    engine.rootContext()->setContextProperty("CUtil",new CUtil());
//    engine.rootContext()->setContextProperty("CLongScreenShot",new CLongScreenShot(&engine));
    engine.rootContext()->setContextProperty("CLongScreenShot",new CLongScreenShotInApp(&engine));

    const QUrl url(u"qrc:/EpLongScreenShot/main.qml"_qs);
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
        &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
    engine.load(url);


//    QQuickView view;
//    const QUrl url(u"qrc:/EpLongScreenShot/main.qml"_qs);
//    view.setSource(url);
//    view.resize(320,480);
//    view.show();

//    view.engine()->rootContext()->setContextProperty("CUtil",new CUtil());
//    view.engine()->rootContext()->setContextProperty("CLongScreenShot",new CLongScreenShot(view.engine()));



    return app.exec();
}
